/**
 * @Author: cest cestrmail@163.com
 * @Date: 2022-12-28 09:30:46
 * @LastEditors: cest cestrmail@163.com
 * @LastEditTime: 2023-02-28 15:38:56
 * @FilePath: /sbm-portal-lite/src/middleware/response.global.js
 * @Description: http.interceptors.response 中间件业务处理
 */
import store from '@/store'

const resolveCode = {
  401: () => {
    console.log('resolveCode 401:', store)
    store.commit('logout')
  },
  403: () => {
    console.log('resolveCode 403:')
  },
  // Resolve other code ...
  '1002':() => {
    console.log('resolveCode 1002:')
    store.commit('logout')
  }
}

const defineResponseMiddleware = code => {
  console.log('defineResponseMiddleware:', code)
  if (resolveCode[code] && typeof resolveCode[code] === 'function') {
    resolveCode[code]()
  }

}

export default defineResponseMiddleware
